//
//  YHFocusCollectionCell.m
//  FAKER
//
//  Created by dllo on 15/11/10.
//  Copyright © 2015年 YHLai. All rights reserved.
//

#import "YHFocusCollectionCell.h"
//#import "AllHeader.h"
#import "FitHeader.h"

@implementation YHFocusCollectionCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        _coverImageView = [[BaseClassImageView alloc] init];
        [CONTENT_VIEW addSubview:_coverImageView];
        
        _titleLabel = [[UILabel alloc] init];
//        _titleLabel.textColor = [UIColor lightGrayColor];
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        _titleLabel.font = [UIFont systemFontOfSize:13];
        [CONTENT_VIEW addSubview:_titleLabel];
        
        [self changeColor];
    }
    return self;
}

//#pragma mark 改变颜色
//- (void)changeColor
//{
//    if (NSUSERDEFAULTS_NIGHT) {
//        self.backgroundColor = BGCOLOR_LIGHTBLACK;
//    } else {
//        self.backgroundColor = BGCOLOR_WHITE;
//    }
//}

- (void)layoutSubviews
{
    [super layoutSubviews];
    _coverImageView.frame = CGRectMake(0, 0, 50, 50);
    _coverImageView.center = CGPointMake(CONTENT_VIEW.center.x, CONTENT_VIEW.center.y - 10);
    _titleLabel.frame = CGRectMake(0, _coverImageView.Y + _coverImageView.HEIGHT + 10, self.contentView.WIDTH, 20);
}

- (void)setFocus:(Focus *)focus
{
    _focus = focus;
    
    //赋值
    [_coverImageView sd_setImageWithURL:[NSURL URLWithString:focus.pic] placeholderImage:[UIImage imageNamed:@"PlaceHolder"]];
    _titleLabel.text = _focus.title;
}

#pragma mark 改变颜色
- (void)changeColor
{
    if (NSUSERDEFAULTS_NIGHT) {
        self.contentView.backgroundColor = BGCOLOR_LIGHTBLACK;
        _titleLabel.textColor = [UIColor lightGrayColor];
    } else {
        self.contentView.backgroundColor = BGCOLOR_WHITE;
        _titleLabel.textColor = [UIColor grayColor];
    }
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
